﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication3
{
    public partial class Form1 : Form
    {
        int rmp;
        double temp;
        bool engine = false;
        public Form1()
        {
            rmp = 0;
            temp = 60;
            InitializeComponent();
            start();
        }

        public void start()
        {
            pictureBox1.Image = imageList1.Images[1];
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if ((temp < 70) && (engine == true)) temp += 0.5;
            if (rmp > 6500) temp += 1;
            if ((rmp < 6500)&&(temp > 70)&&(engine == true)) temp -= 0.5;
            if ((engine == false)&&(temp>60)) temp -= 0.5;
        }


        private void button1_Click(object sender, EventArgs e)
        {
            if (timer2.Enabled == false)
            {
                timer2.Enabled = true;
                button1.Text = "Finish";
            }
            else
            {
                timer2.Enabled = false;
                button1.Text = "Start";
            }

        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            if (rmp < 7300) rmp += 75;
        }

        private void timer3_Tick(object sender, EventArgs e)
        {
            progressBar1.Value = rmp;
            progressBar2.Value = (int)temp;
            label1.Text = ("RMP = " + rmp.ToString());
            label2.Text = ("Temperature = " + ((int)temp).ToString());
        }

        private void timer4_Tick(object sender, EventArgs e)
        {
            if ((rmp < 750)&&(engine == true)) rmp += 75;
            if ((rmp > 750) && (timer2.Enabled == false)&&(engine == true)) rmp -= 50;
            if ((timer2.Enabled == false)&&(engine == false)&&(rmp>0)) rmp -= 50;
            if (rmp < 0) rmp = 0;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (engine == false)
            {
                button2.Text = "Engine stop";
                engine = true;
                pictureBox1.Image = imageList1.Images[0];
                button1.Enabled = true;
            }
            else
            {
                button1.Enabled = false;
                button2.Text = "Engine start";
                engine = false;
                timer2.Enabled = false;
                pictureBox1.Image = imageList1.Images[1];
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {

        }

    }
}
